#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
struct stu
{
	char name[20];
	int score;
	char rank[30];
};
void scoresort(struct stu* arr, int n)
{
	int i = 0;
	for (i = 0; i < n - 1; i++)
	{
		if (arr[i].score < arr[i + 1].score)
		{
			int tmp = arr[i + 1].score;
			arr[i + 1].score = arr[i].score;
			arr[i].score = tmp;
			char arr1[20];
			strcpy(arr1, arr[i + 1].name);
			strcpy(arr[i + 1].name, arr[i].name);
			strcpy(arr[i].name, arr);
		}
	}
}
void ranksort(struct stu* arr, int n)
{
	int i = 0;
	for (i = 0; i < n; i++)
	{
		if (arr[i].score == 0)
		{
			strcpy(arr[i].rank, "Bad");
		}
		else if (arr[i].score >= 1 && arr[i].score < 200)
		{
			strcpy(arr[i].rank, "Not good");
		}
		else if (arr[i].score >= 200 && arr[i].score < 300)
		{
			strcpy(arr[i].rank, "Bronze medal");
		}
		else if (arr[i].score >= 300 && arr[i].score < 400)
		{
			strcpy(arr[i].rank, "Silver medal");
		}
		else if (arr[i].score >= 400 && arr[i].score <= 600)
		{
			strcpy(arr[i].rank, "Gold medal");
		}
	}

}
int main()
{
	struct stu arr[100];
	int n = 0;
	scanf("%d", &n);
	int i = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%s%d%", arr[i].name, &arr[i].score);
	}
	scoresort(arr, n);
	ranksort(arr, n);
	for (i = 0; i < n; i++)
	{
		printf("%s %d %s\n", arr[i].name, arr[i].score, arr[i].rank);
	}
	return 0;
}